package com.masterclient.app.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.masterclient.app.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @auther hjian
 * @date 2019/12/25.
 */
public class RemindDialog extends Dialog {

    @BindView(R.id.dialog_remind_content)
    TextView dialogRemindContent;
    @BindView(R.id.dialog_remind_confirm)
    TextView dialogRemindConfirm;

    private Context context;
    private String confirm, content;

    public RemindDialog(@NonNull Context context, String content, String confirm) {
        super(context, R.style.MyDialog);
        this.content = content;
        this.confirm = confirm;
        this.context = context;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_remind);
        ButterKnife.bind(this);
        setCanceledOnTouchOutside(true);

        dialogRemindConfirm.setText(confirm);
        dialogRemindContent.setText(content);

    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowparams = window.getAttributes();
        windowparams.width = WindowManager.LayoutParams.MATCH_PARENT;
        windowparams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setGravity(Gravity.CENTER);
        window.setBackgroundDrawableResource(R.color.transparent);
        window.setType(WindowManager.LayoutParams.TYPE_APPLICATION_PANEL);
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        window.setAttributes(windowparams);
    }

    @OnClick(R.id.dialog_remind_confirm)
    public void onViewClicked() {
        dismiss();
    }
}
